<template>
  <my-div class="word">
     <head></head>
    <div class="beifen" >
      <image style="width:58px;height:65px;" src="root:img/create/biji@2x.png"></image>
      <my-text :text="$t('login.clone_word')" day_color="rgba(19,32,63,1)" night_color="rgba(102,102,102,1)" style="font-size:36px;margin-top:24px;"></my-text>
      <div class="word-c" style="height:210px">
        <text class="zhujici">{{master_key}}</text>
      </div>
      <my-text text="私钥" day_color="rgba(19,32,63,1)" night_color="rgba(102,102,102,1)" style="font-size:36px;margin-top:24px;"></my-text>
      <div class="word-b">
        <text class="zhujici">{{master_seed}}</text>
      </div>
      <text v-if="show_copy" class="currency-copy" @click="copy">{{$t('wallet.copy')}}</text>

    </div>
    <sure-password ref='sure_pw' @success="sure_success"></sure-password>
  </my-div>
</template>

<script>
import SurePassword from '../../component/sure_password.vue';
const clipboard = weex.requireModule('clipboard')
export default {
  name: '',
  data() {
    return {
      master_key:'',
      master_seed:'',
      show_copy:false
     
    }
  },
  components: {SurePassword},
  computed: {},
  watch: {},
  created() {
    var self = this
    var globalEvent = weex.requireModule('globalEvent') ;
        globalEvent.addEventListener("onPageInit", function (e) {
          const now = new Date().getTime()
          // const last_time = pref.getString('has_sure')
          // ||(now - last_time)>300000 过期时间
          // if(!last_time){
            self.cropty(self.current_wallet.master_key,self.current_wallet.master_seed)
            self.$refs.sure_pw.show = true
          // }else {
          //   self.master_key = self.current_wallet.master_key
          // }
        });
  },
  mounted() {
    //  this.$refs.sure_pw.show = true
  },
  methods: {
    cropty(master_key,master_seed){
      master_key = master_key.replace(/[a-zA-Z]/g,'*')
      master_seed = master_seed.replace(/[0-9]|[a-zA-Z]/g,'*')
      this.master_key = master_key
      this.master_seed = master_seed
    },
    copy(){
      clipboard.setString(this.master_seed)
      this.toast('复制成功')
    },
    sure_success(){
      this.master_key = this.current_wallet.master_key
      this.master_seed = this.current_wallet.master_seed
      this.show_copy = true
    }

  }
}
</script>
<style scoped>
.word{
  position: absolute;
  top: 0;
  bottom: 0;
  flex:1;
}
.beifen{
  margin-top: 80px;
  width: 750px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
}
.attention{
  margin-top: 68px;
  font-size: 28px;
  color: rgba(102,102,102,1);
}
.word-c{
  width: 690px;
  background-color: rgba(70,120,245,0.1);
  padding-top: 44px;
  padding-left: 18px;
  padding-bottom: 44px;
  margin-top: 28px;
  border-radius: 20px;
  padding-right: 18px;
}
.word-b{
  width: 690px;
  height: 60px;
  background-color: rgba(70,120,245,0.1);
  padding-left: 18px;
  margin-top: 28px;
  border-radius: 20px;
  padding-right: 18px;
}
.zhujici{
  font-size: 28px;
  color: rgba(102,102,102,1);
  line-height: 60px;
}
.login-btn{
  width: 690px;
  height: 80px;
  background-color: rgba(70,120,245,1);
  margin-top: 100px;
  border-radius: 10px;
  position: absolute;
  bottom: 140px;
  left: 30px;
}
.currency-copy{
  width: 140px;
  height: 60px;
  margin-top: 20px;
  margin-bottom: 56px;
  font-size: 28px;
  color: rgba(60,71,98,1);
  background-color: rgba(60,71,98,0.1);
  text-align: center;
  line-height: 60px;
  border-radius: 10px;
}

</style>
